require 'jrake'

task :help do
  puts
  puts 'Valid build targets:'
  puts '    clean        - deletes all generated files'
  puts '    main_compile - compiles the main code'
  puts '    unit_compile - compiles the code for the unit tests'
  puts '    unit         - runs the units tests'
  puts '    help         - displays this help text'
  puts '    exit         - quits the application'
  puts
  puts 'A blank line repeats the previous command.'  
  puts
end

task :exit do
  exit
end

task :clean do
  recursive_delete('tmp')
end

task :default => :unit

task :main_compile do
  src_dir = 'src'
  dest_dir = 'tmp/main'
  classpath = ['../vendor/jetty/lib/servlet-api-2.5-6.1.0rc0.jar']

  javac(src_dir, dest_dir, classpath)
end

task :unit_compile => :main_compile do 
  src_dir = 'test/unit'
  dest_dir = 'tmp/test/unit'
  classpath = ['tmp/main', '../vendor/junit/junit-4.1.jar']
  
  javac(src_dir, dest_dir, classpath)
end

task :unit => :unit_compile do
  junit('tmp/test/unit', ['tmp/main'])
end
